<?php
namespace Admin\Controller;

use Think\Model;
use Org\Util;
/**
 * Description of SpProductsController
 *
 * @author Myron
 */
class SpProductstockController extends AddonsController{
    
    /**
    *库存查看页面
    * @author 曹梦龙 <138888611@qq.com>
    */
    public function index(){
        $shopId=I('shopId');
        if($shopId>-1){
        $map['shopId'] =$shopId;
        $this->assign('shopId', $shopId);
        };
        $pCategoryId=I('pid');
        if($pCategoryId>0){
            $map['pCategoryId']= $pCategoryId;
        }
        $name = I('name');
        
        $map['name'] = array('like', '%' . (string) $name . '%');
        $list = $this->lists('sp_productstock', $map);
        int_to_string($list);
        $this->assign('_list', $list);
        $shoplist = M('sp_shops')->where(array('status' => 1))->select();
        $pcategorylist = M('sp_pcategory')->where(array('status' => 1))->order('type')->select();
        $this->assign('pcategorylist', $pcategorylist);
        $this->assign('pCategoryId', $pCategoryId);
        $this->assign('shoplist', $shoplist);
        $this->meta_title = '标题';
        $this->display();
    }
    /*****
     * 库存明显查看
     * @author 曹梦龙 <138888611@qq.com>
     */
    
      public function detail($pid=null,$sid=null,$b_date=null,$e_date=null){
        if(!is_null($pid)){
            $map['shopId']=$sid;
        }
         if(!is_null($sid)){
            $map['productId']=$pid;
        }
        if(!is_null($b_date) && !is_null($e_date)){
            $b=strtotime($b_date);
            $e=strtotime($e_date);           
            $map['createat']  =  array('between',$b.','.$e);
        }
        
        $list = $this->lists('sp_pstockchangedetail', $map);
    
        int_to_string($list);
        $this->assign('_list', $list);
        $this->meta_title = '标题';
        $this->display();
    }
    
}
